package com.paw.portal.enums;

import java.io.Serializable;
import java.util.Arrays;

import com.paw.common.enums.ICommonEnum;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 用户信息表
 * </p>
 *
 * @author Rubble
 * @since 2021-08-21
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="SysUserEnums对象", description="用户信息表Enums对象")
public class SysUserEnums implements Serializable {

@Getter
@AllArgsConstructor
public enum SexEnum implements ICommonEnum {

  /**
   * 用户性别（0：男；1：女；2：未知）
   */
  A0(0,"男"),
  A1(1,"女"),
  A2(2,"未知"),
  ;
  int code;
  String desc;

  public static SexEnum getEnumByCode (Integer code) {
    return code!=null?Arrays.stream(values()).filter(e->e.getCode()==code).findFirst().orElse(null):null;
  }

  public static String getDescByCode (Integer code) {
    return code!=null?Arrays.stream(values()).filter(e->e.getCode()==code).map(SexEnum::getDesc).findFirst().orElse(null):null;
  }
}
@Getter
@AllArgsConstructor
public enum StatusEnum implements ICommonEnum {

  /**
   * 帐号状态（1：正常；0:停用）
   */
  A0(1,"正常"),
  A1(0,"停用"),
  ;
  int code;
  String desc;

  public static StatusEnum getEnumByCode (Integer code) {
    return code!=null?Arrays.stream(values()).filter(e->e.getCode()==code).findFirst().orElse(null):null;
  }

  public static String getDescByCode (Integer code) {
    return code!=null?Arrays.stream(values()).filter(e->e.getCode()==code).map(StatusEnum::getDesc).findFirst().orElse(null):null;
  }
}
}
